import 'package:inmotion_pro/config/r.dart';
import 'package:inmotion_pro/l10n/local.dart';
import 'package:inmotion_pro/service/global_service.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:lx_widgets_library/lx_widgets_library.dart';

import 'controller.dart';

// 注销账号视图
class RemoveAccountView extends BaseGetView<RemoveAccountController> {
  RemoveAccountView({super.key});

  @override
  String get title => local.remove_account;

  @override
  Widget buildBody(BuildContext context) {
    return Scaffold(
      backgroundColor: Colors.black,
      body: Padding(
        padding: EdgeInsets.only(
          top: CONTENT_MARGIN * 2,
          left: CONTENT_MARGIN,
          right: CONTENT_MARGIN,
        ),
        child: Stack(
          children: [
            Column(
              children: [
                LxText(
                  local.delete_the_account_bound_to(
                      GlobalService.to.cacheUserInfo.value.email),
                  fontWeightEnum: LxFontWeightEnum.titleLarge,
                  textAlign: TextAlign.center,
                  color: Colors.white,
                  lineHeight: 1.3,
                ),
                SizedBox(height: CONTENT_MARGIN),
                LxText(
                  local.if_you_delete_this_account,
                  fontWeightEnum: LxFontWeightEnum.bodyMedium,
                  textAlign: TextAlign.center,
                  color: Colors.white,
                  lineHeight: 1.3,
                ),
                SizedBox(height: CONTENT_MARGIN * 2),
                _accountItem(
                  R.removeAccountUserInfoItemIcon,
                  context.s.personal_information,
                ),
                SizedBox(height: CONTENT_MARGIN),
                _accountItem(
                  R.removeAccountVehicleInfoItemIcon,
                  context.s.vehicle_ride_history,
                ),
                SizedBox(height: CONTENT_MARGIN),
                _accountItem(
                  R.removeAccountLogsItemIcon,
                  context.s.vehicle_logs,
                ),
              ],
            ),
            Positioned(
              bottom: tabBarSpace + CONTENT_MARGIN * 2,
              left: 0,
              right: 0,
              child: LxButton(
                height: 44.w,
                borderRadius: BorderRadius.circular(20.w),
                title: context.s.log_off,
                buttonTypeCustomColor: ButtonTypeColor()
                  ..backgroundColor = GrayColor.gray2.withOpacity(0.5)
                  ..borderColor = Colors.transparent
                  ..textColor = Colors.white.withOpacity(0.8),
                onTap: () {
                  controller.logOffOnTap();
                },
              ),
            ),
          ],
        ),
      ),
    );
  }

  Widget _accountItem(String imgPath, String title) {
    return ClipRRect(
      borderRadius: BorderRadius.all(
        Radius.circular(8.w),
      ),
      child: Container(
        color: GrayColor.gray1,
        height: 76.w,
        child: Row(
          children: [
            Padding(
              padding: EdgeInsets.only(left: CONTENT_MARGIN),
              child: Image.asset(
                imgPath,
                width: 44.w,
                fit: BoxFit.fitWidth,
              ),
            ),
            Padding(
              padding: EdgeInsets.only(left: CONTENT_MARGIN),
              child: LxText(
                title,
                fontWeightEnum: LxFontWeightEnum.titleLarge,
                color: Colors.white,
              ),
            ),
          ],
        ),
      ),
    );
  }
}
